package lesson09;

import javax.swing.*;
import java.awt.*;

public class Test05 extends JFrame {
    private Image bgImage = new ImageIcon("images/timg.jpg").getImage();

    private CardLayout cardLayout = new CardLayout();
    private LoginPanel loginPanel = new LoginPanel(this);
    private MainPanel mainPanel = new MainPanel(this);
    public Test05(){


        this.setContentPane(new JPanel(){
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgImage,0,0,this);
            }
        });
        this.setLayout(cardLayout);
        this.add("login",loginPanel);
        this.add("main",mainPanel);
        cardLayout.show(this.getContentPane(),"main");
        this.setTitle("hello");
        this.setIconImage(new ImageIcon("images/logo.png").getImage());
        this.setSize(800,600);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }
    public void switchPanel(String name){
        cardLayout.show(this.getContentPane(),name);
    }
    public static void main(String[] args) {
        new Test05();
    }
}
